﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlphaD.Core
{
    public class SlarStrategy: ISlarStrategy
    {
        public double[] Resolve2(double[,] slar2)
        {
            if (slar2.GetLength(0) != 2 || slar2.GetLength(1) != 3)
            {
                throw new ArgumentException("SLAR extended matrix must have 2 rows and 3 columns");
            }

            double d = slar2[0, 0] * slar2[1, 1] - slar2[1, 0] * slar2[0, 1];
            double d1 = slar2[0, 2] * slar2[1, 1] - slar2[1, 2] * slar2[0, 1];
            double d2 = slar2[0, 0] * slar2[1, 2] - slar2[1, 0] * slar2[0, 2];

            double[] result = new double[2];
            result[0] = d1 / d;
            result[1] = d2 / d;

            return result;
        }

    }
}
